import { ref, reactive } from 'vue'
interface User {
    email: string,
    password: string,
}
interface Rules {
    email: {
        required: boolean;
        type: string;
        message: string;
        trigger: string;
    }[];
    password: ({
        required: boolean;
        message: string;
        trigger: string;
        min?: undefined;
        max?: undefined;
    } | {
        min: number;
        max: number;
        message: string;
        trigger: string;
        required?: undefined;
    })[];
}

export const loginUser = reactive<User>({
    email: "",
    password: "",
});
export const rules = ref<Rules>({
    email: [
        {
            required: true,
            type: 'email',
            message: '请输入邮箱',
            trigger: 'change',
        },
    ],
    password: [
        {
            required: true,
            message: '请输入密码',
            trigger: 'blur',
        },
        {
            min: 1,
            max: 6,
            message: 'Length should be 1 to 6',
            trigger: 'blur',
        },
    ],
})